Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FDP-2929 ~ Adds alarm command handling and ... #44

Merged
merged 7 commits into from
Feb 5, 2025

Conversation

smvdheijden
Copy link
Member

  • Refactors command handling
  • Updates dependency management to use toml file
  • Replaces mockito by mockK

* Refactors command handling
* Updates dependency management to use toml file
* Replaces mockito by mockK

Signed-off-by: Sander van der Heijden <[email protected]>
Signed-off-by: Sander van der Heijden <[email protected]>
Signed-off-by: Sander van der Heijden <[email protected]>
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource

class AlarmCommandHandlerTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing command failures?

Signed-off-by: Sander van der Heijden <[email protected]>
simulatorState.addDownlink(command)
} catch (ex: Exception) {
logger.error { ex }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would except the error logging of the exception at the point where the InvalidCommandException is caught -> in or above handleFailure().

Copy link
Contributor

@sanderv sanderv Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This notation only logs ex.toString(). Use logger.error(ex) { "Your message here" } for full stack trace

} catch (ex: InvalidCommandException) {
handleFailure(command, simulatorState)
}
if (!canHandleCommand(command)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is already done in the MessageHandler, right before handleCommand() is called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Loes and defensive programming can be used as an argument to double check. This can be done in a more concise way in Kotlin:

require(canHandleCommand(command)) { "Alarm command handler can not handle command: $command" }

This throws an IllegalArgumentException

Signed-off-by: Sander van der Heijden <[email protected]>
Signed-off-by: Sander van der Heijden <[email protected]>
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.gxf.crestdevicesimulator.simulator.response.handlers

import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate imports

Signed-off-by: Sander van der Heijden <[email protected]>
@smvdheijden smvdheijden merged commit ac7b59d into main Feb 5, 2025
4 checks passed
@smvdheijden smvdheijden deleted the feature/FDP-2929-alarm-command branch February 5, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants